import os
from fastapi import APIRouter,HTTPException,status,Query

app06 = APIRouter()

@app06.get("/")
async def index():
    return {
        "name":os.path.basename(__file__)
    }

@app06.get("/city/{name}")
async def get_city(name:str):
    if name != "beijing":
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,detail="城市未找到",headers={"x-error":"error"})
    return {
        "city":name
    }

@app06.get("/register")
async def register(name:str = Query(...,max_length=5)):
    return {
        "name":name
    }